﻿<form id="uploadForm" name="uploadForm" method="post" target="uploadResult" action="/ExamPlan/LocalUpload/" enctype="multipart/form-data">
    <div class="modal-header">
        <h3 class="modal-title">
            <i class="fa fa-upload"></i>
            在线导入
        </h3>
    </div>

    <div class="modal-body">
        <!--<input id="uploadify" name="uploadFile" type="file" ng-disabled="loadingState" />-->

        <br />
        <div class="progress" ng-show="loadingState">
            <div class="progress-bar progress-bar-success progress-bar-striped active" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%">
                <span class="sr-only">&nbsp;</span>
            </div>
        </div>
    </div>

    <div class="modal-footer">
        <button id="btnSubmit" type="button" class="btn btn-turquoise" ng-click="upload()" ng-disabled="loadingState">
            <i class="fa fa-upload" ng-hide="loadingState"></i>
            <i class="fa fa-spinner fa-spin" ng-show="loadingState"></i>
            确认导入
        </button>
        <button id="btnCancel" type="button" class="btn btn-gray" ng-click="close();" ng-disabled="loadingState">
            <i class="fa fa-close"></i>
            关闭
        </button>
    </div>
</form>

<iframe id="uploadResult" name="uploadResult" style="display:none;"></iframe>

<div id="UploadResult" style="display: none;">
    <div class="modal-header">
        <h3 class="modal-title">
            <i class="fa fa-check"></i>
            成功导入<span id="txtSubjectCount"></span>门考试！
            <input id="txtExamMode" type="hidden" value="" />
        </h3>
    </div>

    <div class="modal-body">
        <div class="row">
            <label class="control-label col-sm-4 text-right">考试计划名称：</label>
            <label id="txtPlanName" class="control-label col-sm-8"></label>
        </div>

        <div class="row">
            <label class="control-label col-sm-4 text-right">科目列表：</label>
            <label id="txtSubjects" class="control-label col-sm-8"></label>
        </div>

        <div class="row">
            <label class="control-label col-sm-4 text-right">场次列表：</label>
            <label id="txtExamScenes" class="control-label col-sm-8"></label>
        </div>
    </div>

    <div class="modal-footer">
        <button type="button" class="btn btn-turquoise" ng-click="afterUpload();">
            <i class="fa fa-check"></i>
            确认
        </button>
    </div>
</div>

<script>
    //uploadInterval = window.setInterval(function () {
    //    $('#btnUploading').click();
    //}, 5000);

    //window.clearInterval(uploadInterval);

    //$(function () {
    //    var uploadInterval;
    //    $("#uploadify").uploadify({
    //        swf: 'App/vendor/uploadify/uploadify.swf',
    //        uploader: 'Manager/ExamPlan/LocalUpload',
    //        queueID: 'fileQueue',
    //        auto: false,
    //        multi: false,
    //        buttonText: '选择文件',
    //        fileTypeDesc: '考试计划包文件',
    //        fileTypeExts: '*.oepp;',
    //        height: 80,
    //        width: 80,
    //        queueSizeLimit: 1,
    //        removeTimeout: 1,

    //        onUploadStart: function (file) {
    //            formDisabled();

    //            uploadInterval = window.setInterval(function () {
    //                $('#btnUploading').click();
    //            }, 5000);
    //        },
    //        onUploadComplete: function (file) {
    //            formEnabled();
    //        },
    //        onUploadSuccess: function (file, data, response) {
    //            data = JSON.parse(data);

    //            window.clearInterval(uploadInterval);
    //            formEnabled();

    //            if (data.ResultType == ResultType.Success) {
    //                $('#UploadResult').show().siblings().hide();

    //                $('#txtSubjectCount').empty().text(data.data.SubjectList.length);
    //                $('#txtPlanName').empty().text(data.data.ExamPlanInfo.ExamPlanName);
    //                $('#txtExamMode').empty().val(data.data.examMode);

    //                // 显示科目列表数据
    //                var objSubjects = $('#txtSubjects');
    //                objSubjects.empty();
    //                for (var i = 0; i < data.data.SubjectList.length; i++) {
    //                    var curTxt = objSubjects.text();
    //                    if (i != 0)
    //                        curTxt += '、';
    //                    curTxt += data.data.SubjectList[i].SubjectName;

    //                    objSubjects.text(curTxt);
    //                }

    //                // 显示场次列表数据
    //                var objScenes = $('#txtExamScenes');
    //                objScenes.empty();

    //                for (var i = 0; i < data.data.ExamScenesList.length; i++) {
    //                    var curTxt = objScenes.text();
    //                    if (i != 0)
    //                        curTxt += '、';
    //                    curTxt += data.data.ExamScenesList[i].ExamSceneName;

    //                    objScenes.text(curTxt);
    //                }
    //            } else {
    //                $('#btnCancel').click();
    //                alert(data.Message);
    //            }
    //        },
    //        onSelectError: function (file, errorCode, errorMsg) {
    //            var msgText = "上传失败\n";
    //            switch (errorCode) {
    //                case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED:
    //                    msgText += "每次最多上传 " + this.settings.queueSizeLimit + "个文件";
    //                    break;
    //                case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
    //                    msgText += "文件大小超过限制( " + this.settings.fileSizeLimit + " )";
    //                    break;
    //                case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
    //                    msgText += "文件大小为0";
    //                    break;
    //                case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
    //                    msgText += "文件格式不正确，仅限 " + this.settings.fileTypeExts;
    //                    break;
    //                default:
    //                    msgText += "错误代码：" + errorCode + "\n" + errorMsg;
    //            }
    //            alert(msgText);

    //            window.clearInterval(uploadInterval);
    //            formEnabled();
    //        },
    //        onUploadError: function (file, errorCode, errorMsg, errorString) {
    //            // 手工取消不弹出提示
    //            if (errorCode == SWFUpload.UPLOAD_ERROR.FILE_CANCELLED
    //                || errorCode == SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED) {
    //                return;
    //            }
    //            var msgText = "上传失败\n";
    //            switch (errorCode) {
    //                case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:
    //                    msgText += "HTTP 错误\n" + errorMsg;
    //                    break;
    //                case SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL:
    //                    msgText += "上传文件丢失，请重新上传";
    //                    break;
    //                case SWFUpload.UPLOAD_ERROR.IO_ERROR:
    //                    msgText += "IO错误";
    //                    break;
    //                case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:
    //                    msgText += "安全性错误\n" + errorMsg;
    //                    break;
    //                case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
    //                    msgText += "每次最多上传 " + this.settings.uploadLimit + "个";
    //                    break;
    //                case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:
    //                    msgText += errorMsg;
    //                    break;
    //                case SWFUpload.UPLOAD_ERROR.SPECIFIED_FILE_ID_NOT_FOUND:
    //                    msgText += "找不到指定文件，请重新操作";
    //                    break;
    //                case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED:
    //                    msgText += "参数错误";
    //                    break;
    //                default:
    //                    msgText += "文件:" + file.name + "\n错误码:" + errorCode + "\n"
    //                        + errorMsg + "\n" + errorString;
    //            }
    //            alert(msgText);

    //            window.clearInterval(uploadInterval);
    //            formEnabled();
    //        }
    //    });
    //});
</script>